import static org.junit.Assert.*;

import org.junit.Test;

/**
 * 
 */

/**
 * @author Liqun zhang
 *
 */
public class VendingMachineItemTest {
    /**
     * Test VendingMachineItem constructor with price >0 
     */
	@Test
	public void testVendingMachineItemValidPrice() {
		VendingMachineItem I1 = new VendingMachineItem("Candy",1.25);
		assertNotNull(I1);
		assertEquals("Candy",I1.getName());
		assertEquals(1.25,I1.getPrice(),0);
	}
	/**
     * Test VendingMachineItem constructor with price=0 
     */
	@Test
	public void testVendingMachineItemPriceZero() {
		VendingMachineItem I1 = new VendingMachineItem("Chips",0);
		assertNotNull(I1);
		assertEquals("Chips",I1.getName());
		assertEquals(0,I1.getPrice(),0);
	}
	/**
	 * Test VendingMachineItem constructor with price < 0
	 */
	@Test
	public void testVendingMachineIteminValidPrice(){
		try{
			new VendingMachineItem("SunChips",-1.00);
		}
		catch(VendingMachineException vme){
		}
	}
	/**
	 * Test method for {@link VendingMachineItem#getName()}.
	 */
	@Test
	public void testGetName() {
		VendingMachineItem I1 = new VendingMachineItem("Candy",1.25);
		String name = I1.getName();
		assertEquals("Candy",name);
	}

	/**
	 * Test method for {@link VendingMachineItem#getPrice()}.
	 */
	@Test
	public void testGetPrice() {
		VendingMachineItem I1 = new VendingMachineItem("Candy",1.25);
		double price = I1.getPrice();
		assertEquals(1.25,price,0);
	}

}
